#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <utility>
#include <map>
#include <set>

// 使用typedef定义新类型
typedef std::vector<int> IntVector;

// 定义一个简单的类层次结构用于动态转换示例
class Base {
public:
    virtual ~Base() {
    }
};

class Derived : public Base {
};

int main() {
    // std::string示例
    std::string s = "Hello, World!";
    std::cout << "std::string: " << s << std::endl;

    // std::vector示例
    std::vector<int> v = {1, 2, 3, 4, 5};
    std::cout << "std::vector: ";
    for (int num: v) {
        std::cout << num << " ";
    }
    std::cout << std::endl;

    // std::array示例
    std::array<int, 3> a = {1, 2, 3};
    std::cout << "std::array: ";
    for (int num: a) {
        std::cout << num << " ";
    }
    std::cout << std::endl;

    // std::pair示例
    std::pair<int, float> p(10, 3.14f);
    std::cout << "std::pair: first = " << p.first << ", second = " << p.second << std::endl;

    // std::map示例
    std::map<int, std::string> m;
    m[1] = "One";
    m[2] = "Two";
    std::cout << "std::map: key = 1, value = " << m[1] << std::endl;

    // std::set示例
    std::set<int> st = {1, 2, 3, 3, 2, 1};
    std::cout << "std::set: ";
    for (int num: st) {
        std::cout << num << " ";
    }
    std::cout << std::endl;

    // typedef使用示例
    IntVector intVec = {100, 200, 300};
    std::cout << "typedef定义的IntVector: ";
    for (int num: intVec) {
        std::cout << num << " ";
    }
    std::cout << std::endl;

    // 枚举类型示例
    enum class Weekday {
        Monday = 1,
        Tuesday,
        Wednesday,
        Thursday,
        Friday,
        Saturday,
        Sunday
    };
    Weekday today = Weekday::Tuesday;
    std::cout << "enum Weekday: today is " << static_cast<int>(today) << std::endl;

    // 静态转换示例
    int intValue = 20;
    float floatValue = static_cast<float>(intValue);
    std::cout << "static_cast: int " << intValue << " convert float " << floatValue << std::endl;

    // 动态转换示例
    Base *basePtr = new Derived();
    Derived *derivedPtr = dynamic_cast<Derived *>(basePtr);
    if (derivedPtr) {
        std::cout << "success" << std::endl;
    } else {
        std::cout << "fail" << std::endl;
    }
    delete basePtr;

    return 0;
}
